{% extends "layout.html" %}
{% from "_formhelpers.html" import render_field %}
{% from "_formhelpers.html" import render_navigation %}

{% block body %}

  <div>
    <table>
      <thead>
      <tr>
        {% for field in model._fields_ordered %}
          <th>{{ model[field].verbose_name or model[field].name}}</th>
        {% endfor %}
        <th>Edit</th>
      </tr>
      </thead>
      <tbody>
      {% for page_object in page.items %}
        <tr>
          {% for field in page_object._fields_ordered %}
            <td>{{ page_object[field] }}</td>
          {% endfor %}
          <td><a href="{{ url_for(view, pk=page_object.pk) }}">edit</a></td>
        </tr>
      {% endfor %}
      </tbody>
    </table>
  </div>
  <div>
    {{ render_navigation(page, view) }}
  </div>
  <div>
    <form method="POST">
      {% for field in form %}
        {{ render_field(field, style='font-weight: bold') }}
      {% endfor %}
      <input type="submit" value="{% if form.instance %}Edit{% else %}Create{% endif %}">
    </form>
  </div>

{% endblock %}
